<!--
 * @Descripttion: 
 * @version: @ 1.0.0
 * @Author: 朱江洲
 * @Date: 2022-06-02 08:42:50
 * @LastEditors: 朱江洲
 * @LastEditTime: 2022-06-02 09:49:55
-->
<template>
  <div>
    <el-dialog
      title="报名信息修改"
      :visible.sync="dialog.editManShow"
      width="50%"
      @close="editManClose"
    >
      <div class="main">
        <div
          v-for="(item, index) in formList"
          :key="index"
          class="main-content"
          v-show="item.isHidden"
        >
          <main-con
            :formList="item"
            class="main-con"
            ref="mainContent"
          ></main-con>
        </div>
      </div>
      <span slot="footer">
        <el-button @click="dialog.editManShow = false">取消</el-button>
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { updateList, updateManagement } from "@/api/registration";
import MainCon from "../mainCon.vue";
export default {
  props: {
    dialog: {
      type: Object,
      required: true,
    },
    drawerData: {
      type: Object,
      required: true,
    },
  },
  components: {
    MainCon,
  },
  data() {
    return {
      formList: [],
    };
  },
  created() {
    this.getDetailInfo();
  },
  methods: {
    // 确认修改
    onSubmit() {
      let fd = new FormData();
      fd.append("customFields", JSON.stringify(this.formList));
      fd.append("batchId", this.drawerData.batchId);
      fd.append("personId", this.drawerData.personId);
      updateManagement(fd).then((res) => {
        this.$message.success(res.msg);
        this.dialog.editManShow = false;
      });
    },
    // 关闭报名信息修改
    editManClose() {
      this.dialog.editManShowEject = false;
    },
    // 获取报名信息数据
    getDetailInfo() {
      updateList({
        examId: this.drawerData.examId,
        batchId: this.drawerData.batchId,
        personId: this.drawerData.personId,
      }).then((res) => {
        this.formList = res.data;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  width: 100%;
  .main-content {
    width: 48%;
  }
}
</style>